package cn.passlink.bletoothchat.Tools.Emoji;

import android.text.SpannableStringBuilder;
import android.text.style.ClickableSpan;
import android.view.View;

public class EmojiSpannableStringBuilder extends SpannableStringBuilder {

    private String clickedEmoji;

    public void setClickedEmoji(String emoji) {
        this.clickedEmoji = emoji;
    }

    public String getClickedEmoji() {
        return clickedEmoji;
    }

    @Override
    public void setSpan(Object what, int start, int end, int flags) {
        super.setSpan(new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                if (clickedEmoji != null) {
                    widget.callOnClick();
                }
            }
        }, start, end, flags);
    }
}